<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>事件对象</title>
    <style>
      div {
        width: 100px;
        height: 100px;
        background-color: pink;
        margin-top: 10px;
      }
    </style>
    <script src="lib/jQuery-v3.6.0.min.js"></script>
  </head>
  <body>
    <a href="https://www.baidu.com" target="_black">百度</a>
    <div></div>

    <script>
      $(function () {
        $('a').click(function (e) {
          // 阻止默认行为
          e.preventDefault()
        })

        $(document).on('click', function () {
          console.log('点击了 document')
        })
        $('div').on('click', function (e) {
          console.log('点击了 div')
          // 阻止事件冒泡
          e.stopPropagation()
        })
      })
    </script>
  </body>
</html>
